@echo off
setlocal enabledelayedexpansion

:: 设置变量
set JAR_FILE="path\to\your\service.jar"
set CHECK_URL="http://www.baidu.com11111"
set TIMEOUT_SECONDS=30
set RESTART_DELAY_SECONDS=5
set HTTP_CODE=
set port=8088

:CHECK_RESPONSE
echo 123
:: 使用curl获取HTTP响应码
for /F %%a in ('curl -so NUL -w "%%{http_code}" %CHECK_URL%') do (
    set HTTP_CODE=%%a
)
echo %HTTP_CODE%

:: 检查HTTP响应码
if "%HTTP_CODE%" NEQ "200" (
    

for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do (
  if "%%d" == "LISTENING" (
    set pid=%%e
    echo !pid!
                taskkill /f /pid !pid!
    goto :end
   )
 )
  
  echo [INFO] 123
    
) else (
    echo [INFO] The service at '%CHECK_URL%' is responsive.
)

:: 设置循环检测间隔时间
timeout /T %TIMEOUT_SECONDS%
goto CHECK_RESPONSE
